﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace windows.实验一
{
    class Class5
    {
        static void Main(string[] args)
        {
            int sum = 0;
            for (int i = 1; i < 21; i++)
            {
                sum = sum + Fib(i);
            }
            #region 求斐波那契数列前20项的和
            Console.WriteLine("斐波那契数列前20项之和：{0}" , sum);
            Console.ReadKey();
            #endregion
        }

        private static int Fib(int v)
        {
            if(v > 2)
            {
                return Fib(v - 1) + Fib(v - 2);
            }
            else if (v==1 || v==2)
            {
                return 1;
            }
            else
            {
                return 0;
            }
        }
    }
}
